package com.hfzy.ihk.web.callhistoryold.utils.kafka;

import kafka.producer.KeyedMessage;

import java.util.Random;

/**
 * Created by Administrator on 2017/3/20.
 */
public class KafkaUtil {
    private static Random r=new Random();
    public static void send(String topic,String value) {
        try {
            if(KafkaProperties.partition==0){
                CacheQueue.put(new KeyedMessage<String, String>(topic,value));
            }else{
                String key = String.valueOf(r.nextInt(KafkaProperties.partition));
                CacheQueue.put(new KeyedMessage<String, String>(topic,key,value));
            }

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
